﻿// Decompiled with JetBrains decompiler
// Type: Netick.NetworkString32
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;
using System.Text;

#nullable disable
namespace Netick;

/// <summary>
/// Represents a fixed-size network-serializable string with a maximum length of 32 characters.
/// </summary>
[Serializable]
public struct NetworkString32
{
  internal const int Size = 32 /*0x20*/;
  public FixedSize32<ushort> RawValue;

  public unsafe NetworkString32(string value)
  {
    fixed (NetworkString32* ptrChar = &this)
      NetworkStringHelper.SetString(value, (char*) ptrChar, Math.Min(32 /*0x20*/, value.Length));
  }

  public unsafe void LoadIntoStringBuilder(StringBuilder stringBuilder)
  {
    fixed (NetworkString32* ptr = &this)
      NetworkStringHelper.LoadPtrStringIntoStringBuilder(stringBuilder, (char*) ptr, 32 /*0x20*/);
  }

  public override unsafe string ToString()
  {
    fixed (NetworkString32* ptrChar = &this)
      return NetworkStringHelper.GetString((char*) ptrChar, 32 /*0x20*/);
  }

  public static implicit operator NetworkString32(string val) => new NetworkString32(val);

  public static implicit operator string(NetworkString32 val) => val.ToString();
}
